package com.aaie.gru.user.service.impl;

import com.aaie.gru.user.entity.GruSysGuardianSchoolMap;
import com.aaie.gru.user.entity.GruSysGuardianSchoolMapVo;
import com.aaie.gru.user.mapper.GruSysGuardianSchoolMapMapper;
import com.aaie.gru.user.service.IGruSysGuardianSchoolMapService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 监护人和学校映射表（多对多） 服务实现类
 * </p>
 *
 * @author lvxing
 * @since 2019-08-17
 */
@Service
public class GruSysGuardianSchoolMapServiceImpl extends ServiceImpl<GruSysGuardianSchoolMapMapper, GruSysGuardianSchoolMap> implements IGruSysGuardianSchoolMapService {

    @Resource
    GruSysGuardianSchoolMapMapper gruSysGuardianSchoolMapMapper;

    @Override
    public List<GruSysGuardianSchoolMapVo> getSchoolListByGuardian(String guardianId) {
        QueryWrapper<GruSysGuardianSchoolMapVo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("gsm.guardian_id", guardianId);
        queryWrapper.orderByDesc("school.user_name");
        return gruSysGuardianSchoolMapMapper.selectSchoolListByGuardian(queryWrapper);
    }
}
